package cc.spider.web.model.http;

import java.io.Serializable;

public class RequestBody implements Serializable {
    public static class ContentType {

        public static final String JSON = "application/json";

        public static final String XML = "text/xml";

        public static final String FORM = "application/x-www-form-urlencoded";

        public static final String MULTIPART = "multipart/form-data";

        private ContentType() {
        }
    }

    private String body;

    private String contentType = "application/x-www-form-urlencoded";

    private String encoding = "UTF-8";

    public RequestBody() {

    }

    public RequestBody(String body, String contentType, String encoding) {
        this.body = body;
        this.contentType = contentType;
        this.encoding = encoding;
    }

    public String getBody() {
        return body;
    }

    public void setBody(String body) {
        this.body = body;
    }

    public String getContentType() {
        return contentType;
    }

    public void setContentType(String contentType) {
        this.contentType = contentType;
    }

    public String getEncoding() {
        return encoding;
    }

    public void setEncoding(String encoding) {
        this.encoding = encoding;
    }


    public static RequestBody stringBody(String body, String contentType, String encoding) {
        return byteBody(body, contentType, encoding);
    }

    public static RequestBody byteBody(String body, String contentType, String encoding) {
        return new RequestBody(body, contentType, encoding);
    }

}
